package redis

import (
	"gitee.com/csingo/cDB/drivers"
)

const (
	Driver drivers.DBDriver = "redis"
)

type Connection struct {
	Driver       drivers.DBDriver `json:"driver"`
	Host         string           `json:"host"`
	Port         int64            `json:"port"`
	Auth         string           `json:"auth"`
	DB           int64            `json:"db"`
	Retries      int64            `json:"retries"`
	DialTimeout  int64            `json:"dial_timeout"`
	ReadTimeout  int64            `json:"read_timeout"`
	WriteTimeout int64            `json:"write_timeout"`
	Pool         *ConnectionPool  `json:"pool"`
}

type ConnectionPool struct {
	Size         int64 `json:"size"`
	MinIdleConns int64 `json:"min_idle_conns"`
	PoolTimeout  int64 `json:"pool_timeout"`
	IdleTimeout  int64 `json:"idle_timeout"`
}

func (i *Connection) GetDriver() drivers.DBDriver {
	return i.Driver
}

func (i *Connection) IsDebug() bool {
	return false
}

func (i *Connection) NewConnector(name string) (drivers.ConnectorInterface, error) {
	return NewRedisConnector(name, i)
}
